<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/layui/css/layui.css"  media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>

<script src="layui/layui.js"></script>

<body>
<center>
    <h3>添加商品小分类</h3>

    <form class="layui-form" action="/category/addCategory">
        <!--    <div class="layui-form-item">-->
        <!--        <label class="layui-form-label">用户账号</label>-->
        <!--        <div class="layui-input-block">-->
        <!--            <input id="id" type="text" name="id" lay-verify="title" autocomplete="on" class="layui-input">-->
        <!--        </div>-->
        <!--    </div>-->

        <div class="layui-form-item">
            <label class="layui-form-label">商品小分类编号</label>
            <div class="layui-input-block">
                <input id="categoryId" type="text" name="categoryId" lay-verify="title" autocomplete="on" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">商品小分类名称(*)</label>
            <div class="layui-input-block">
                <input id="categoryName" type="text" name="categoryName" lay-verify="title" autocomplete="on" class="layui-input">
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">商品所属大类别编号</label>
            <div class="layui-input-block">
                <input id="classId" type="text" name="classId" lay-verify="title" autocomplete="on" class="layui-input">
            </div>
        </div>

        <br>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>

    </form>

</center>
</body>

<script>

    layui.use(['upload', 'element', 'layer'], function(){
        var $ = layui.jquery
            ,upload = layui.upload
            ,element = layui.element
            ,layer = layui.layer;

        //拖拽上传
        upload.render({
            elem: '#test10'
            ,url: 'user/upload'
            ,done: function(res){
                layer.msg('上传成功');
                layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', res.msg);
                console.log(res)
            }
        });
    });


    //Demo
    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){
            layer.msg(JSON.stringify(data.field));//把表单中数据转成Json并输出
            //可以写一些验证
            return true;//true表示执行action对应的地址
        });
    });
</script>

</html>